/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package motiveai.tests;

import motiveai.annotation.DurationOfBehaviour;
import motiveai.components.BehaviourEntity;
import motiveai.factors.Environment;

/**
 *
 * @author oxplay
 */
public class Test4AttackEnemy extends BehaviourEntity<Test4Agent> {
    
    Test4DamageCalculator calculator = new Test4DamageCalculator();
    
    public Test4AttackEnemy() {
    }

    public boolean canBeUsed(Test4Agent agent, Environment environment) {
        if (environment.getIntegerFactor("closeEnemyType") > 0 && environment.getBooleanFactor("inAttackRange")) {
            return true;
        }
        return false;
    }

    @Override
    @DurationOfBehaviour(duration = 0.3f)
    public float behave(Test4Agent agent, Environment environment) {
        //agent.getManager().printDebugInformation();
        agent.actualBehaviour = "Attack!";
        float val = (float)calculator.attack("normal", agent, environment)/10f;
        return val;
    }
}
